.TH SETUP 8
.SH NAME
setup \- Install MINIX 3 on a hard disk
.SH SYNOPSIS
setup
.SH DESCRIPTION
.tr ~ 
.nr a 0 +1
.de CB
.sp 0.5v
\s-1\\f5\\c
..
.de CE
\\fR\\s0\\c
.sp 0.5v
..
.de IT
.ti -0.25i
.PP
..
.PP
This appendix explains how to install MINIX 3.
Standard MINIX 3 requires a Pentium (or compatible) with at least
16-MB of RAM, at least 200-MB of free disk space, an IDE CD-ROM and an
IDE hard disk. Serial ATA, USB, and SCSI disks are not supported at present.
For USB CD-ROMS, see the Website: \fIwww.minix3.org\fR.

\fBPREPARATION\fR
.PP
If you already have the CD-ROM (e.g., from the book), you can skip steps 1 and
2, but it is wise to check \fIwww.minix3.org\fR to see if a newer version
is available.
If you want to run MINIX 3 on a simulator instead of native, see Part V first.
If you do not have an IDE CD-ROM, 
either get the special USB CD-ROM boot image or use a simulator.

.IT "Download the MINIX 3 CD-ROM image"
Download the MINIX 3 CD-ROM image from the MINIX 3 Website
at \fIwww.minix3.org\fR.

.IT "Create a bootable MINIX 3 CD-ROM"
Decompress the downloaded file.
You will get a CD-ROM image file with extension \fI.iso\fR and this manual.
The \fI.iso\fR file is a bit-for-bit CD-ROM image.
Burn it to a CD-ROM to make a bootable CD-ROM.
.PP
If you are using \fIEasy CD Creator 5\fR, select \*(OQRecord CD from CD image\*(CQ from the File
menu and change the file type from \fI.cif\fR to \fI.iso\fR in the dialog box that
appears. Select the image file and click \*(OQOpen.\*(CQ Then click \*(OQStart Recording.\*(CQ
.PP
If you are using \fINero Express 5\fR, choose \*(OQDisc Image or Saved Project\*(CQ and
change the type to \*(OQImage Files,\*(CQ select the image file and click \*(OQOpen.\*(CQ
Select your CD recorder and click on \*(OQNext.\*(CQ
.PP
If you are running Windows and do not have a CD-ROM burning program, take a look at
.br
\fIalexfeinman.brinkster.net/isorecorder.htm\fR
.br
for a free one and use it to create
a CD image.

.IT "Determine which Ethernet Chip you have"
.PP
MINIX 3 supports several Ethernet chips for networking over LAN, ADSL, and
cable. These include Intel Pro/100, RealTek 8029 and 8139, AMD LANCE,
and several 3Com chips.
During setup
you will be asked which Ethernet chip you have, if any. Determine that now by
looking at your documentation. Alternatively, if you are using Windows, go to
the device manager as follows:
.sp 1
.ta 0.9i
Windows 2000:	
.br
Start> Settings> Control Panel> System> Hardware> Device Mgr
.sp 1
Windows XP:	
.br
Start> Control Panel> System> Hardware> Device Mgr\s0
.ll -1i
.sp 1
System requires double clicking; the rest are single. Expand the + next to
\*(OQNetwork adapters\*(CQ to see what you have. Write it down. If you do not have
a supported chip, you can still run MINIX 3, but without Ethernet.

.IT "Partition your hard disk"
.PP
You can boot the computer from your CD-ROM if
you like and MINIX 3 will start, but to do anything useful, you have to create a
partition for it on your hard disk.
But before partitioning, be sure to \fBback up your data to an external med\%ium
like CD-ROM or DVD\fR as a safety precaution, just in case something goes wrong.
Your files are valuable; protect them.
.PP
Unless you are sure you are an expert on disk partitioning with much experience, it is strongly suggested that you
read the online tutorial on disk partitioning
at \fIwww.minix3.org/doc/partitions.html.\fR
If you already know how to manage partitions, create a contiguous chunk of free
disk space of at least 200 MB (even better: 400 MB or more).
If you do not know how to manage partitions but have a partitioning program
like \fIPartition Magic\fR, use it to create a region of free disk space of at
least 200 MB. Also make sure there is at least one primary partition (i.e.,
Master Boot Record slot) free.
The MINIX 3 setup script will guide you through creating a MINIX partition in the 
free space, which can be on either the first or second IDE disk.
.PP
If you are running Windows 95, 98, ME, or 2000 \fIand\fR your disk consists of a single
FAT partition, you can use the \fIpresz134.exe\fR program on the CD-ROM
(also available at \fIzeleps.com\fR) to reduce its size to leave room for MINIX.
In all other cases, please read the online tutorial cited above.
.PP
\fBWARNING: If you make a mistake during disk partitioning, you can lose all the data
on the disk, so be sure to back it up to CD-ROM or DVD before starting.
Disk partitioning requires great care, so proceed with caution.\fR

\fBBOOTING\fR
.nr a 0 
.PP
By now you should have allocated at least 200 MB of free space on your disk.
If you have not done so yet, please do it now unless there is an existing
200-MB (or larger) partition you are willing to convert to MINIX 3.

.IT "Boot from the CD-ROM"
Insert the CD-ROM into your CD-ROM drive and boot the computer from it.
If you have 16 MB of RAM or more, choose \*(OQRegular;\*(CQ 
if you have only 8 MB choose \*(OQsmall.\*(CQ
If the computer boots from the hard disk instead of the CD-ROM, boot again and enter the
BIOS setup program to change the order of boot devices, putting the CD-ROM before
the hard disk.

.IT "Login as root"
When the \fIlogin\fR prompt appears, login as \fIroot.\fR
After a successful login as root, you will see the shell prompt (#).
At this point you are running fully-operational MINIX 3. If you type:
.PP
   ls /usr/bin | more
.PP
you can see what software is available.
Hit space to scroll the list. 
To see what program \fIfoo\fR does, type:
.PP
   man foo
.PP
The manual pages are also available at
.br
\fIwww.minix3.org/manpages\fR. 

.IT "Start the setup script"
To start the installation of MINIX 3 on the hard disk, type
.PP
   setup
.PP
After this and all other commands, be sure to type ENTER (RETURN).
When the installation script ends a screen with a colon, hit ENTER to
continue. If the screen suddenly goes blank, press CTRL-F3 to select
software scrolling (should only be needed on very old computers).
Note that CTRL-key means depress the CTRL key and while holding it down,
press \*(OQkey.\*(CQ

\fBINSTALLING TO THE HARD DISK\fR
.nr a 0
.PP
These steps correspond to the steps on the screen.

.IT "Select keyboard type"
When you are asked to select your national keyboard, do so. 
This and other steps have a default choice, in square brackets.
If you agree with it, just hit ENTER. In most steps, the default is generally
a good choice for beginners.
The us-swap keyboard interchanges the CAPS LOCK and CTRL keys, as is conventional
on UNIX systems.

.IT "Select your Ethernet chip"
You will now be asked which of the available Ethernet driver you want
in\%stalled (or none). Please choose one of the options.

.IT "Basic minimal or full install?"
If you are tight on disk space, select M for a minimal installation
which includes all the binaries but only the system sources installed.
200 MB is enough for a bare-bones system. If you have 400 MB or more,
choose F for a full installation.

.IT "Create or select a partition for MINIX 3"
You will first be asked if you are an expert in MINIX 3 disk partitioning.
If so, you will be placed in the \fIpart\fR program to give you full power to
edit the Master Boot Record (and enough rope to hang yourself).
If you are not an expert, press ENTER for the default action, which is an
automated step-by-step guide to formatting a disk partition for MINIX 3.

\fBSubstep 4.1: Select a disk to install MINIX 3\fR
.PP
An IDE controller may have up to four disks. The \fIsetup\fR script will now
look for each one. Just ignore an error messages.
When the drives are listed, select one. and confirm your choice.
If you have two hard disks and you decide to install MINIX 3 to the second one and have
trouble booting from it, please see \fIwww.minix3.org/doc/using2disks.html\fR
for the solution.

\fBSubstep 4.2: Select a disk region\fR
.PP
Now choose a region to install MINIX 3 into. You have three choices:
.sp 0.5v
   (1) Select a free region
   (2) Select a partition to overwrite
   (3) Delete an existing partition to free up space and merge with adjacent free 
space
.sp 0.5v
For choices (1) and (2), type the region number. For (3) type
.sp -0.25v
.PP
   delete
.PP
.sp -0.25v
then give the region number when asked. 
This region will be overwritten and its previous contents lost forever.

\fBSubstep 4.3: Confirm your choices\fR
.PP
You have now reached the point of no return. You will be asked if you want to
continue. \fBIf you do, the data in the selected region will be lost forever.\fR
If you are sure, type:
.PP
   yes
.PP
and then ENTER. To exit the setup script without changing the
partition table, hit CTRL-C.

.IT "Reinstallation choice"
If you chose an existing MINIX 3 partition, in this step you will be
offered a choice between a Full install, which erases everything in the
partition, and a Reinstall, which does not affect your existing \fI/home\fR
partition. This design means that you can put your personal files on
\fI/home\fR and reinstall a newer version of MINIX 3 when it is available
without losing your personal files.

.IT "Select the size of /home"
The selected partition will be divided into three subpartitions: root, \fI/usr\fR,
and \fI/home\fR. The latter is for your own personal files. Specify how much of the
partition should be set aside for your files.
You will be asked to confirm your choice.

.IT "Select a block size"
Disk block sizes of 1-KB, 2-KB, 4-KB, and 8-KB are supported, but
to use a size larger than 4-KB you have to change a constant and recompile
the system. If your memory is 16 MB or more, use the default (4 KB); 
otherwise, use 1 KB.

.IT "Wait for bad block detection"
The setup script will now scan each partition for bad disk blocks. This will take
several minutes, possibly 10 minutes or more on a large partition.
Please be patient.
If you are absolutely certain there are no bad blocks, you can kill each scan
by hitting CTRL-C.

.IT "Wait for files to be copied"
When the scan finishes, files will be automatically copied from the CD-ROM to
the hard disk. Every file will be announced as it is copied. 
When the copying is complete, MINIX 3 is installed.
Shut the system down by typing
.PP
   shutdown
.PP
Always stop MINIX 3 this way to avoid data loss as MINIX 3 keeps some files on
the RAM disk and only copies them back to the hard disk at shutdown time.


\fBTESTING\fR
.nr a 0
.PP
This section tells you how to test your installation, rebuild the system after
modifying it, and boot it later. To start, boot your new MINIX 3 system.
For example, if you used controller 0, disk 0, partition 3, type
.PP
   boot c0d0p3
.PP
and log in as root. Under very rare conditions the drive number seen by the
BIOS (and used by the boot monitor) may not agree with the one used by
MINIX 3, in which case try other drive numbers.
This is a good time to create a root password. See \fIman passwd\fR for help.

.IT "Compile the test suite"
To test MINIX 3, at the command prompt (#) type
.PP
   cd /usr/src/test
.br
   make
.PP
and wait until it completes all 40 compilations.
Log out by typing CTRL-D,

.IT "Run the test suite"
To test the system, log in as bin (required) and type
.PP
   cd /usr/src/test
.br
   ./run
.PP
to run the test programs. They should all run correctly but they can take
20 min on a fast machine and over an hour on a slow one.
\fINote\fR: It is necessary to compile the test suite when running as root
but execute it as bin in order to see if the setuid bit works correctly.

.IT "Rebuild the entire operating system"
If all the tests work correctly, you can now rebuild the system.
Doing so is not necessary since it comes prebuilt, but
if you plan to modify the system, you will need to know how to rebuild it.
Besides, rebuilding the system is a good test to see if it works. Type:
.PP
   cd /usr/src/tools
.br
   make
.PP
to see the various options available. Now make a new bootable image by typing
.PP
   su
   make clean
   time make image
.PP
You just rebuilt the operating system, including all the kernel and user-mode
parts. That did not take very long, did it?
If you have a legacy floppy disk drive, you can make a
bootable floppy for use later by inserting a formatted floppy and typing
.PP
   make fdboot
.PP
When you are asked to complete the path, type:
.PP
   fd0
.PP
This approach does not currently work with USB floppies since there is no MINIX 3 USB
floppy disk driver yet. 
To update the boot image currently installed on the hard disk, type
.PP
   make hdboot
.PP

.IT "Shut down and reboot the new system"
To boot the new system, first shut down by typing:
.PP
   shutdown
.PP
This command saves certain files and returns you to the MINIX 3 boot monitor.
To get a summary of what the boot monitor can do, while in it, type:
.PP
   help
.PP
For more details, see \fIwww.minix3.org/manpages/man8/boot.8.html\fR.
You can now remove any CD-ROM or floppy disk and turn off the computer.

.IT "Booting Tomorrow"
.PP
If you have a legacy floppy disk drive, the simplest way to boot MINIX 3 is by
inserting your new boot floppy and turning on the power. It takes only a few seconds.
Alternatively, boot from the MINIX 3 CD-ROM, login as bin and type:
.PP
   shutdown
.PP
to get back to the MINIX 3 boot monitor. Now type:
.PP
   boot c0d0p0
.PP
to boot from the operating system image file on
controller 0, driver 0, partition 0.
Of course, if you put MINIX 3 on drive 0 partition 1, use:
.PP
   boot c0d0p1
.PP
and so on.
.PP
A third possibility for booting is to make the MINIX 3 partition the active one,
and use the MINIX 3 boot monitor to start MINIX 3 or any other operating system.
For details
see \fIwww.minix3.org/manpages/man8/boot.8.html\fR.
.PP
Finally, a fourth option is for you to install a multiboot loader such as
LILO or GRUB (\fIwww.gnu.org/software/grub\fR).
Then you can boot any of your operating systems easily. 
Discussion of multiboot loaders is beyond the scope of this guide, but there
is some information of the subject at \fIwww.minix3.org/doc\fR.

\fBUSING A SIMULATOR\fR
.nr a 0
.PP
A completely different approach to running MINIX 3 is to run it
on top of another operating system instead of native on the bare
metal. Various virtual machines, simulators, and emulators are
available for this purpose. Some of the most popular ones are:

   \(bu VMware (www.vmware.com)
.br
   \(bu Bochs (www.bochs.org)
.br
   \(bu QEMU (www.qemu.org)
.sp 1v
See the documentation for each of them. Running a program on a
simulator is similar to running it on the actual machine, so you
should go back to Part I and acquire the latest CD-ROM and continue
from there.

